﻿using CodeGenerator.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeGenerator.Template.Web.Models
{
    public partial class ListModel : ITemplate
    {
        public MetaData Data { get; set; }
        public List<LookupClassModel> lookups { get; set; }
        public List<PickupListModel> pickuplist { get; set; }

        public string Filename
        {
            get { return "List{ClassName}Model.cs"; }
        }
        public string FolderName
        {
            get { return ""; }
        }

        public bool IsGenerateOneTime { get { return false; } }
        public bool IsGenerateFolder { get { return false; } }
        public bool IsRequiredOnlyOneMember { get { return true; } }
        public GenerateStyle GenerateStyle { get { return GenerateStyle.Normal; } }

        public MultipleSelectedModel getParent(MultipleSelectedModel multiModel, List<MultipleSelectedModel> groupMultiModel)
        {
            MultipleSelectedModel parentMulti = null;
            if (multiModel.Level != 1 && multiModel.Parent != null)
            {
                parentMulti = groupMultiModel.Where(m => m.Id == multiModel.Parent.Id).DefaultIfEmpty().First();
            }
            if (parentMulti != null) return parentMulti;
            else return null;
        }
    }


}
